/* eslint-disable */
<template>
  <div class="footStatis-container">
    <div class="footStatis-title">菜品交易统计</div>
    <div class="searchselect">
      <market @listenEvent="mkfn" />
      <dateselect @listenEvent="dtfn" />
      <foottype @listenEvent="fofn" />
    </div>
    <div class="form">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="name" label="商户名称"></el-table-column>
        <el-table-column prop="topTypeName" label="类别"></el-table-column>
        <el-table-column label="均价">
          <el-table-column prop="avgPrice" label="当前（元）"></el-table-column>
          <el-table-column prop="lastAvgPrice" label="环比（元）"></el-table-column>
          <el-table-column prop="lastAvgPriceRate" label="趋势"></el-table-column>
        </el-table-column>
        <el-table-column label="销量">
          <el-table-column prop="weight" label="当前（公斤）"></el-table-column>
          <el-table-column prop="lastWeight" label="环比（公斤）"></el-table-column>
          <el-table-column prop="lastWeightRate" label="趋势"></el-table-column>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
/* eslint-disable */
import market from "@/views/modules/market";
import dateselect from "@/views/modules/dateselect";
import foottype from "@/views/modules/foottype";
export default {
  name: "footStatis",
  components: {
    market,
    dateselect,
    foottype
  },
  data() {
    return {
      marketArray: [],
      tableData: [],
      date: {
        marketId: 0,
        startDate: "2020-07-17",
        endDate: "2020-07-17",
        businessType: -1
      }
    };
  },
  created() {},
  mounted() {
    //  this.mkfn();
    //  this.dtfn();
    this.getstatisfood();
  },
  // watch:{
  //   date(){
  //     console.log(this.date)
  //   }
  // },
  methods: {
    getstatisfood() {
      this.$store
        .dispatch("statisfood/getstatisfood", this.date)
        .then(data => {
          // console.log(data);
          this.tableData = data;
          for (var i = 0; i < this.tableData.length; i++) {
            this.tableData[i].avgPrice = (
              this.tableData[i].avgPrice / 100
            ).toFixed(2);
            this.tableData[i].lastAvgPrice = (
              this.tableData[i].lastAvgPrice / 100
            ).toFixed(2);
            this.tableData[i].lastAvgPriceRate =
              (this.tableData[i].lastAvgPriceRate * 100).toFixed(2) + "%";

            this.tableData[i].weight = (
              this.tableData[i].weight / 1000
            ).toFixed(2);
            this.tableData[i].lastWeight = (
              this.tableData[i].lastWeight / 1000
            ).toFixed(2);
            this.tableData[i].lastWeightRate =
              (this.tableData[i].lastWeightRate * 100).toFixed(2) + "%";
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    mkfn(param) {
      this.date.marketId = param.marketId;
      // console.log(this.date);
      this.getstatisfood();
    },
    dtfn(param) {
      this.date.startDate = param.startDate;
      this.date.endDate = param.endDate;
      // console.log(this.date);
      this.getstatisfood();
    },
    fofn(param) {
      this.date.businessType = param.businessType;
      // this.date.endDate=param.endDate;
      // console.log(this.date);
      this.getstatisfood();
    }
  }
};
</script>
<style lang="scss" scoped>
.footStatis {
  &-container {
    margin: 20px;
  }
  &-title {
    font-size: 18px;
    line-height: 46px;
    background: white;
    margin-bottom: 15px;
    padding-left: 15px;
  }
}

.searchselect {
  background: #ffffff;
  margin-bottom: 15px;
  padding: 10px;
  padding-bottom: 4px;
}
.echarts {
  text-align: center;
  height: 300px;
  background: #fff;
  margin-bottom: 15px;
}
::v-deep thead.is-group th {
 background: #e5e5e5;
}
::v-deep .el-table .cell {
  text-align: center;
}
</style>